{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "635d8ebb",
   "metadata": {},
   "source": [
    "# Getting Started on Windows\n",
    "\n",
    "- Author: [Wooseok-Jeong](https://github.com/jeong-wooseok)\n",
    "- Peer Review: [Yun Eun](https://github.com/yuneun92), [MinJi Kang](https://www.linkedin.com/in/minji-kang-995b32230/)\n",
    "- Proofread : [Q0211](https://github.com/Q0211)\n",
    "- This is a part of [LangChain Open Tutorial](https://github.com/LangChain-OpenTutorial/LangChain-OpenTutorial)\n",
    "\n",
    "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/LangChain-OpenTutorial/LangChain-OpenTutorial/blob/main/01-Basic/01-Getting-Started-Windows.ipynb)[![Open in GitHub](https://img.shields.io/badge/Open%20in%20GitHub-181717?style=flat-square&logo=github&logoColor=white)](https://github.com/LangChain-OpenTutorial/LangChain-OpenTutorial/blob/main/01-Basic/01-Getting-Started-Windows.ipynb)\n",
    "## Overview\n",
    "\n",
    "This tutorial explains how to install the LangChain package on Windows environment. You can easily build a development environment by cloning the required github repository, batch installing the same packages as the author via pyenv, Poetry, installing Visual Studio Code and Jupyter Extension.\n",
    "\n",
    "### Table of Contents\n",
    "\n",
    "- [Overview](#overview)\n",
    "- [Install git](#install-git)\n",
    "- [Install pyenv](#install-pyenv)\n",
    "- [Install Poetry](#install-poetry)\n",
    "- [Install Visual Studio Code](#install-visual-studio-code)\n",
    "- [Install Jupyter Extension](#install-jupyter-extension)\n",
    "\n",
    "### References\n",
    "- [Download git](https://git-scm.com/download/win)\n",
    "- [Download Visual Studio Code](https://code.visualstudio.com/download)\n",
    "\n",
    "----\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "38fe3f6f",
   "metadata": {},
   "source": [
    "## Install git\n",
    "[Download git](https://git-scm.com/download/win)\n",
    "\n",
    "Download 64-bit Git for Windows Setup\n",
    "\n",
    "![git-download](./assets/01-follow-the-installation-video-windows-01.png)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5189c83b",
   "metadata": {},
   "source": [
    "Confirm options during installation and proceed\n",
    "\n",
    "![](./assets/01-follow-the-installation-video-windows-02.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a91429c1",
   "metadata": {},
   "source": [
    "Click the Next button for all the rest to proceed with the installation.\n",
    "\n",
    "![](./assets/01-follow-the-installation-video-windows-03.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a49c86df",
   "metadata": {},
   "source": [
    "Window key - PowerShell must be run as administrator\n",
    "\n",
    "Enter the command \"```git```\" and verify that the output looks like the image below\n",
    "```powershell1\n",
    "git\n",
    "```\n",
    "\n",
    "![](./assets/01-follow-the-installation-video-windows-04.png)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "459858ca",
   "metadata": {},
   "source": [
    "- Apply PowerShell Policy \n",
    "\n",
    "First, run **Windows PowerShell** as an \"administrator.\"</p> <p><br>\n",
    "\n",
    "Enter the following command to apply the policy\n",
    "```powershell\n",
    "Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force\n",
    "```\n",
    "After the application is complete, turn Windows PowerShell off and then on. For the purposes of the following, \"Run as administrator\" when running Windows PowerShell."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8773e420",
   "metadata": {},
   "source": [
    "## Install pyenv\n",
    "Install pyenv before installing python. pyenv installs a virtualization environment to prevent conflicts between packages.\n",
    "\n",
    "```bash\n",
    "git clone https://github.com/pyenv-win/pyenv-win.git \"$env:USERPROFILE\\.pyenv\"\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bcc00279",
   "metadata": {},
   "source": [
    "- Add environment variables\n",
    "\n",
    "Copy and paste the content below and run it\n",
    "```powershell\n",
    "[System.Environment]::SetEnvironmentVariable('PYENV', $env:USERPROFILE + \"\\.pyenv\\pyenv-win\\\", \"User\")\n",
    "[System.Environment]::SetEnvironmentVariable('PYENV_ROOT', $env:USERPROFILE + \"\\.pyenv\\pyenv-win\\\", \"User\")\n",
    "[System.Environment]::SetEnvironmentVariable('PYENV_HOME', $env:USERPROFILE + \"\\.pyenv\\pyenv-win\\\", \"User\")\n",
    "```\n",
    "\n",
    "Copy and paste the content below and run it\n",
    "```powershell\n",
    "[System.Environment]::SetEnvironmentVariable('PATH', $env:USERPROFILE + \"\\.pyenv\\pyenv-win\\bin;\" + $env:USERPROFILE + \"\\.pyenv\\pyenv-win\\shims;\" + [System.Environment]::GetEnvironmentVariable('PATH', \"User\"), \"User\")\n",
    "```\n",
    "\n",
    "Shut down and rerun the current Windows PowerShell.\n",
    "\n",
    "Enter the following command to verify that it works.\n",
    "```powershell\n",
    "pyenv\n",
    "```\n",
    " \n",
    "![](./assets/01-follow-the-installation-video-windows-05.png )\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3abfe733",
   "metadata": {},
   "source": [
    "- Install python\n",
    "\n",
    "Install Python version 3.11\n",
    "```powershell\n",
    "pyenv install 3.11\n",
    "```\n",
    "Setting 3.11 version of python as the default runtime\n",
    "```powershell\n",
    "pyenv global 3.11\n",
    "```\n",
    "Check your Python version\n",
    "```powershell\n",
    "python --version\n",
    "```\n",
    "Make sure you have version 3.11.9 installed (or 3.11.11 is fine too!)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fe99bcaf",
   "metadata": {},
   "source": [
    "## Install Poetry\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6eef27ed",
   "metadata": {},
   "source": [
    "Run the command below to install the Poetry package management tool.\n",
    "```bash\n",
    "pip3 install poetry\n",
    "```\n",
    "\n",
    "- [Link to LangChain-OpenTutorial.git](https://github.com/LangChain-OpenTutorial/LangChain-OpenTutorial.git)\n",
    "\n",
    "Navigate to the Documents folder.\n",
    "\n",
    "```powershell\n",
    "cd ~/Documents\n",
    "```\n",
    "\n",
    "Execute the command below to get the source code.\n",
    "```powershell\n",
    "git clone https://github.com/LangChain-OpenTutorial/LangChain-OpenTutorial.git\n",
    "```\n",
    "\n",
    "Execute the command below to navigate to the LangChain-OpenTutorial directory.\n",
    "```powershell\n",
    "cd LangChain-OpenTutorial\n",
    "```\n",
    "\n",
    "Setting up a Python virtual environment\n",
    "```powershell\n",
    "poetry shell\n",
    "```\n",
    "Batch update Python packages\n",
    "```powershell\n",
    "poetry update\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb9bf1a4",
   "metadata": {},
   "source": [
    "## Install Visual Studio Code\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "efb44c79",
   "metadata": {},
   "source": [
    "Download Visual Studio Code\n",
    "\n",
    "- [Download Visual Studio Code](https://code.visualstudio.com/download)\n",
    "\n",
    "Install the downloaded Visual Studio Code (copy it to the Applications folder)\n",
    "\n",
    "Click 'install' of Jupyter on left Menu of extensions \n",
    "\n",
    "![](./assets/01-follow-the-installation-video-windows-06.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "83d19633",
   "metadata": {},
   "source": [
    "## Install Jupyter Extension\n",
    "Search for \"python\" and install\n",
    "\n",
    "![](./assets/01-follow-the-installation-video-windows-07.png)\n",
    "\n",
    "Search for \"jupyter\" and install\n",
    "\n",
    "![](./assets/01-follow-the-installation-video-windows-08.png)\n",
    "\n",
    "Turn off and restart Visual Studio Code\n",
    "\n",
    "The installation is complete, and you can click the \"select kernel\" button in the top right corner.\n",
    "\n",
    "Click python environment - if you don't see the virtual environment you installed, turn off Visual Studio Code and restart it"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "LangChain Tutorial",
   "language": "python",
   "name": "langchain-tutorial"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
